import { msgError, msgInfo } from '@/utils/msg';
import { Badge } from 'antd';
import {
  Button,
  LoadPanel,
  NumberBox,
  RadioGroup,
  ScrollView,
  SelectBox,
  TextBox,
  Toolbar,
} from 'devextreme-react';
import { Item } from 'devextreme-react/toolbar';
import { ClickEvent } from 'devextreme/ui/button';
import { CSSProperties, forwardRef, useContext, useEffect, useRef, useState } from 'react';
import { CpasIcon } from '~/public/cpas-ui';
import { consts } from '../../consts';
import {
  LayerExtractType,
  OverallMode,
  SampleMethod,
  SampleParmeterProps,
  SampleSizeAndAmount,
  SampleSizeMethod,
  SampleStepInfo,
  StatSampleParameter,
  SystemExtractType,
  WhereSqlParams,
} from '../../typing';
import '../index.less';
import {
  getSampleOverallWhereSQL,
  iniFormQueryAndAdvParams,
} from '../samplingProjectOverallService';
import { SampleStepInfoContext } from '../samplingRecordPopup';
import { textBoxSelectAll } from '../service';
import { ExpansionCoefficientPopup } from './Coefficient/ExpansionCoefficientPopup';
import { getExpansionCoefficient } from './Coefficient/ExpansionCoefficientService';
import { RiskCoefficientPopup } from './Coefficient/RiskCoefficientPopup';
import {
  acceptableDevArray,
  acceptableRiskArray,
  getRiskCoefficient,
} from './Coefficient/RiskCoefficientService';
import {
  calcSpecialSampleInfo,
  clearPropsSampleParameterValues,
  getAmountMarjorWhereSql,
  getDefaultLayerRanges,
  getDefaultSampleSortFields,
  getIniSampledResult,
  getIniSampleSizeAndAmount,
  getNeedCalcLayerSampleSize,
  getRedStarHtml,
  getSampledResultTable1,
  getSampleListByWhereSql,
  getSampleSizeAndAmount,
  getStatSampleMethodList,
  getToBeTestWhereSql,
  getTrySampleResult,
  getUnimportantWhereSql,
  getValueTextTop500,
  getWhereSqlBySampleList,
} from './NonStatSampleService';
import { LayerSample } from './SampleMethod/LayerSample';
import { ManualSample } from './SampleMethod/ManualSample';
import { PPSSample } from './SampleMethod/PPSSample';
import { RandomSample } from './SampleMethod/RandomSample';
import { SystemSample } from './SampleMethod/SystemSample';
import { getSystemSampleNos } from './SampleMethod/SystemSampleService';
import { ViewSampleListPopup } from './ViewSampleListPopup';

/**
 * 统计抽样
 */
export const StatSample = forwardRef((props: SampleParmeterProps, ref: any) => {
  const propsSampleParameterValues = props.sampleStepInfoOfParams?.sampleParameterValues; //编辑传入的
  //风险系数
  const riskCoefficientPopupRef = useRef<any>();
  const [isNeedRiskCoefficientPopup, setIsNeedRiskCoefficientPopup] = useState<boolean>(false);
  //扩张系数
  const expansionCoefficientPopupRef = useRef<any>();
  const [isNeedExpansionCoefficientPopup, setIsNeedExpansionCoefficientPopup] =
    useState<boolean>(false);

  const viewSampleListPopupRef = useRef<any>();
  //用来模拟点击,执行计算
  const btnStatCalcRef = useRef<any>();
  //分层抽样
  const layerSampleRef = useRef<any>();
  //任意选样
  const manualSampleRef = useRef<any>();
  const [isNeedViewSampleListPopup, setIsNeedViewSampleListPopup] = useState<boolean>(false);
  //上级传入的抽样参数(注:此组件中sampleStepInfo.sampleParameterValues值不可用,下一步才可用)
  const sampleStepInfo: SampleStepInfo = useContext(SampleStepInfoContext);
  const [loading, setLoading] = useState<boolean>(false);

  //非统计抽样参数
  const [statSampleParameter, setStatSampleParameter] = useState<StatSampleParameter>(() => {
    let statSampleParameter2: StatSampleParameter = {
      tolerableMiss: 0,
      amountMajorMin: 0,
      unimportantMax: 0,
      majorMisstatementRisk: '',
      otherSubstantiveRisk: '',
      measurementSampleSize: 0, //sampleStepInfo.projectOverallProps?.curSampleTableTotalCount || 0,
      sampleMethod: SampleMethod.system,

      specialAmountSum: 0, //特殊样本 金额合计
      specialSampleSize: 0, //特殊样本 个数
      specialSampledNumFields: {}, //特殊样本 已抽样字段统计值

      amountMajorAmountSum: 0, //金额重大样本 金额合计
      amountMajorSampleSize: 0, //金额重大样本  个数
      amountMajorSampledNumFields: {}, //金额重大样本 已抽样字段统计值

      unimportantAmountSum: 0, //极不重要样本 金额合计
      unimportantSampleSize: 0, //极不重要样本  个数

      toBeTestAmountSum: 0, //待测试的金额合计
      toBeTestSampleSize: 0, //待测试的个数

      guaranteeCoefficient: 0, //    保证系数

      //统计抽样
      expectedOverallMiss: 0, // number//D.预计总体错报
      sampleInterval: 0, //number;//样本间隔
      riskCoefficient: 0, // number;//风险系数
      expansionCoefficient: 0, // number; // 扩张系数

      randomSampleParams: {
        extractNumber: 0,
        useReproducible: true,
        seed: Math.floor(Math.random() * consts.randomSeed), //一万以内的随机数
      }, //随机

      ppsSampleParams: {
        extractNumber: 0,
        useReproducible: true,
        seed: Math.floor(Math.random() * consts.randomSeed), //一万以内的随机数
      }, //pps
      systemSampleParams: {
        //系统
        sampleSortFields: getDefaultSampleSortFields(sampleStepInfo.projectOverallProps),
        extractType: SystemExtractType.asc,
        interval: 0,
        extractNumber: 0,
      },
      //分层抽样
      layerSampleParams: {
        extractType: LayerExtractType.amountBigToSmall,
        layerRanges: getDefaultLayerRanges(sampleStepInfo, 0, 0, 0), //toBeTestSampleSize
        // isManualEdit: false,
      },
      //任意抽样
      manualSampleParams: {
        sampledAmountSum: 0,
        sampledSize: 0,
        sampledList: [],
        manualWhereSql: '',
        sampleTextFieldValues: [],
      },
      //样本列表手工追加的样本 参数
      manualAddParams: {
        sampledAmountSum: 0,
        sampledSize: 0,
        sampledList: [],
        manualWhereSql: '',
        sampleTextFieldValues: [],
      },
      sampledResult: getIniSampledResult(), //抽样结果,不包含 重大项目和特殊项目
      sampleSizeMethod:
        window.main.mainObject?.getUserConfig()?.auditSample?.sampleSizeMethod ||
        SampleSizeMethod.systemOut, //样本量计算方式
    };

    //如果有传入参数,要合并
    if (props.sampleStepInfoOfParams?.sampleParameterValues) {
      statSampleParameter2 = {
        ...statSampleParameter2,
        ...props.sampleStepInfoOfParams.sampleParameterValues,
      };
    }

    calcAmountSampleSize(statSampleParameter2);

    return statSampleParameter2;
  });
  const isSystemOutCalc = statSampleParameter.sampleSizeMethod == SampleSizeMethod.systemOut;
  const isSystemOutCalcDisplay = isSystemOutCalc ? 'none' : '';
  const systemOutHint =
    window.main.mainObject?.getUserConfig()?.auditSample?.systemOutHint ||
    '请使用带宏的样本计算器计算';

  const sampleMethodOnValueChanged = (e: any) => {
    calcAmountSampleSize();
    //让手工重算吧
    /*   if (e.value == SampleMethod.layer) {
              //如果是层次抽样要重算未抽样数量
              layerSampleRef.current?.reCalcUnSampleSize();
          } */
    setStatSampleParameter({ ...statSampleParameter, sampleMethod: e.value });
  };
  /*  function window_message_event(e: any) {
         const params = e.data; //jsonObject
         if (params.msgType == 'layerSampleReCalcUnSampleSize') {
             layerSampleRef.current?.reCalcUnSampleSize();
         }
     }*/
  useEffect(() => {
    if (ref) {
      ref.current = {
        getSampleParameterValues: () => {
          return statSampleParameter;
        },
        setSampleParameterValues: setStatSampleParameter,
        calcAmountSampleSizeAndUpdate: async () => {
          //计算重大金额和极不重要金额
          await btnStatCalcRef.current.click(); //第1次,不行
          await btnStatCalcRef.current.click(); //第2次,不行
          await btnStatCalcRef.current.click(); //第3次,才行
        },
      };
    }
  }, [statSampleParameter]);

  useEffect(() => {
    const layerRanges = statSampleParameter.layerSampleParams?.layerRanges;
    if (layerRanges?.length == 1 && layerRanges[0].rangeValue == 0) {
      layerRanges[0].unSampleSize =
        sampleStepInfo.projectOverallProps?.curSampleTableTotalCount || 0;
    }

    let statSampleParameter2: StatSampleParameter = {
      ...statSampleParameter,
      systemSampleParams: {
        ...statSampleParameter.systemSampleParams,
        sampleSortFields: getDefaultSampleSortFields(sampleStepInfo.projectOverallProps),
      },
      measurementSampleSize: 0,
      layerSampleParams: {
        ...statSampleParameter.layerSampleParams,
        layerRanges: layerRanges,
      },
    };
    //如果有传入参数,要合并
    if (props.sampleStepInfoOfParams?.sampleParameterValues) {
      statSampleParameter2 = {
        ...statSampleParameter2,
        ...props.sampleStepInfoOfParams.sampleParameterValues,
      };
      calcAmountSampleSize(statSampleParameter2);
    }

    //非统计抽样参数
    setStatSampleParameter(statSampleParameter2);
  }, [
    sampleStepInfo.projectOverallProps?.curSampleTable,
    sampleStepInfo.projectOverallProps?.curSampleTableTotalCount,
  ]);

  // const significantMissValue = statSampleParameter.guaranteeCoefficient?.significantMissValue;
  const sampleMethodStyle = {
    marginTop: 5,
    marginLeft: -0,
    marginRight: 0,
    padding: 0,
    borderRadius: 5,
  };
  /**
   * 查看样本界面
   */
  const viewSampleListByWhereSql = (fieldTitle: string, sampleSize?: number, whereSql?: string) => {
    if (sampleSize == 0) {
      return msgError(fieldTitle + ' 样本为空');
    }
    setIsNeedViewSampleListPopup(true);
    const projectOverallProps = sampleStepInfo.projectOverallProps
      ? JSON.parse(JSON.stringify(sampleStepInfo.projectOverallProps))
      : {};

    const sampleWhereSQL = getSampleOverallWhereSQL(
      projectOverallProps?.curWhereSqlParams as WhereSqlParams,
    );
    projectOverallProps.overallMode = OverallMode.view;
    projectOverallProps.fixedWhereSql = sampleWhereSQL + whereSql;
    //初始化界面查询参数和高级查询参数;
    iniFormQueryAndAdvParams(projectOverallProps);
    const interval = setInterval(() => {
      if (viewSampleListPopupRef.current) {
        clearInterval(interval);

        viewSampleListPopupRef.current.show({
          title: fieldTitle,
          sampleProjectOverallProps: projectOverallProps,
          setIsNeedViewSampleListPopup: setIsNeedViewSampleListPopup,
        });
      }
    }, 10);
  };
  /**
   * 风险系数表
   */
  function openRiskCoefficientPopup() {
    setIsNeedRiskCoefficientPopup(true);
    const interval = setInterval(() => {
      if (riskCoefficientPopupRef.current) {
        clearInterval(interval);
        riskCoefficientPopupRef.current.show({
          setIsNeedPopup: setIsNeedRiskCoefficientPopup,
        });
      }
    }, 10);
  }
  /**
   * 风险系数表
   */
  function openExpansionCoefficientPopup() {
    setIsNeedExpansionCoefficientPopup(true);
    const interval = setInterval(() => {
      if (expansionCoefficientPopupRef.current) {
        clearInterval(interval);
        expansionCoefficientPopupRef.current.show({
          setIsNeedPopup: setIsNeedExpansionCoefficientPopup,
        });
      }
    }, 10);
  }

  async function measurementSampleSizeValueChange() {
    //清除样本编辑参数,为了 只修改样本规模时,才重新计算
    clearPropsSampleParameterValues(propsSampleParameterValues);
    calcAmountSampleSize();
    setStatSampleParameter({ ...statSampleParameter });
  }
  //特殊样本
  function selectSpecialSampleListPopup(e: ClickEvent): void {
    setIsNeedViewSampleListPopup(true);
    const projectOverallProps = sampleStepInfo.projectOverallProps
      ? JSON.parse(JSON.stringify(sampleStepInfo.projectOverallProps))
      : {};
    const sampleWhereSQL = getSampleOverallWhereSQL(
      projectOverallProps?.curWhereSqlParams as WhereSqlParams,
    );
    
    projectOverallProps.overallMode = OverallMode.select;
    projectOverallProps.fixedWhereSql = sampleWhereSQL;
    //初始化界面查询参数和高级查询参数;
    iniFormQueryAndAdvParams(projectOverallProps);
    const interval = setInterval(async () => {
      if (viewSampleListPopupRef.current) {
        clearInterval(interval);

        const specialSampleList = statSampleParameter.specialWhereSql
          ? await getSampleListByWhereSql(sampleStepInfo, statSampleParameter.specialWhereSql)
          : [];

        viewSampleListPopupRef.current.show({
          title: '选择特定样本',
          sampleProjectOverallProps: projectOverallProps,
          specialSampleList: specialSampleList, //statSampleParameter.specialSampleList || [],
          setIsNeedViewSampleListPopup: setIsNeedViewSampleListPopup,
          okCallback: async (newSpecialSampleList: any[]) => {
            // 计算特殊样本信息
            await calcSpecialSampleInfo(
              sampleStepInfo,
              statSampleParameter,
              newSpecialSampleList,
              true,
              calcAmountSampleSize,
            );
            setStatSampleParameter({ ...statSampleParameter });
            setIsNeedViewSampleListPopup(false);
          },
        });
      }
    }, 10);
  }
  const thStyle: CSSProperties = {
    textAlign: 'center',
    fontSize: 16,
    fontWeight: 'bold',
    border: '1px solid #ccc',
    backgroundColor: '#f5f5f5',
  };
  const tableStye: CSSProperties = {
    /*  border: '1px solid #ccc', */ width: '100%',
    borderRadius: 5,
  };
  /**
   * 金额重在大小和金额
   */
  async function getSampleSizeAndAmountOfAmountMajorMin(
    inStatSampleParameter?: StatSampleParameter,
    notCalcAndSet?: boolean,
  ) {
    if (!inStatSampleParameter) inStatSampleParameter = statSampleParameter;
    inStatSampleParameter.amountMajorWhereSql = '';
    let sampleSizeAndAmount: SampleSizeAndAmount = getIniSampleSizeAndAmount();
    if (inStatSampleParameter.amountMajorMin != 0) {
      inStatSampleParameter.amountMajorWhereSql = getAmountMarjorWhereSql(
        sampleStepInfo,
        inStatSampleParameter,
      );
      sampleSizeAndAmount = await getSampleSizeAndAmount(
        sampleStepInfo,
        inStatSampleParameter.amountMajorWhereSql,
      );
      inStatSampleParameter.amountMajorSampledNumFields = {
        ...sampleSizeAndAmount.sampledNumFields,
      };
    }
    inStatSampleParameter.amountMajorAmountSum = sampleSizeAndAmount.amountSum;
    inStatSampleParameter.amountMajorSampleSize = sampleSizeAndAmount.sampleSize;

    //再计算一次 2024-11-11
    const specialSampleList = inStatSampleParameter.specialWhereSql
      ? await getSampleListByWhereSql(sampleStepInfo, inStatSampleParameter.specialWhereSql)
      : [];

    await calcSpecialSampleInfo(
      sampleStepInfo,
      inStatSampleParameter,
      specialSampleList,
      false,
      undefined,
    );
    if (!notCalcAndSet) {
      calcAmountSampleSize();
      setStatSampleParameter({ ...inStatSampleParameter });
    }
  }
  /**
   * 金额重在大小和金额
   */
  async function getSampleSizeAndAmountOfUnimportantMax(
    inStatSampleParameter?: StatSampleParameter,
    notCalcAndSet?: boolean,
  ) {
    if (!inStatSampleParameter) inStatSampleParameter = statSampleParameter;
    inStatSampleParameter.unimportantWhereSql = '';
    let sampleSizeAndAmount: SampleSizeAndAmount = getIniSampleSizeAndAmount();
    if (inStatSampleParameter.unimportantMax != 0) {
      inStatSampleParameter.unimportantWhereSql = getUnimportantWhereSql(
        sampleStepInfo,
        inStatSampleParameter,
      );
      sampleSizeAndAmount = await getSampleSizeAndAmount(
        sampleStepInfo,
        inStatSampleParameter.unimportantWhereSql,
      );
    }
    inStatSampleParameter.unimportantAmountSum = sampleSizeAndAmount.amountSum;
    inStatSampleParameter.unimportantSampleSize = sampleSizeAndAmount.sampleSize;

    //再计算一次 2024-11-11
    const specialSampleList = inStatSampleParameter.specialWhereSql
      ? await getSampleListByWhereSql(sampleStepInfo, inStatSampleParameter.specialWhereSql)
      : [];

    await calcSpecialSampleInfo(
      sampleStepInfo,
      inStatSampleParameter,
      specialSampleList,
      false,
      undefined,
    );

    if (!notCalcAndSet) {
      calcAmountSampleSize();
      setStatSampleParameter({ ...inStatSampleParameter });
    }
  }
  //可容忍错报值改变
  async function tolerableMissValueChange() {
    calcAmountSampleSize();
    setStatSampleParameter({ ...statSampleParameter });
  }
  //预计总体错报值改变
  async function expectedOverallMissValueChange() {
    calcAmountSampleSize();
    setStatSampleParameter({ ...statSampleParameter });
  }
  /**
   * 获取待测试的金额
   */
  function calcAmountSampleSize(inStatSampleParameter?: StatSampleParameter) {
    if (!inStatSampleParameter) inStatSampleParameter = statSampleParameter;

    const old_toBeTestSampleSize = inStatSampleParameter.toBeTestSampleSize || 0;
    const old_toBeTestAmountSum = inStatSampleParameter.toBeTestAmountSum || 0;
    const old_measurementSampleSize = inStatSampleParameter.measurementSampleSize || 0;

    const curSampleTableAmountSum =
      sampleStepInfo.projectOverallProps?.curSampleTableAmountSum || 0; // 1
    const curSampleTableTotalCount =
      sampleStepInfo.projectOverallProps?.curSampleTableTotalCount || 0; //
    //需要测试总体金额
    const { amountMajorAmountSum, specialAmountSum, unimportantAmountSum } = inStatSampleParameter; //2/3/4行
    inStatSampleParameter.toBeTestAmountSum = curSampleTableAmountSum - (amountMajorAmountSum || 0);

    inStatSampleParameter.toBeTestAmountSum =
      inStatSampleParameter.toBeTestAmountSum < 0 ? 0 : inStatSampleParameter.toBeTestAmountSum;

    //B.待抽样的测试总体(扣除特定项目后)
    const { amountMajorSampleSize, specialSampleSize, unimportantSampleSize } =
      inStatSampleParameter;
    inStatSampleParameter.toBeTestSampleSize =
      curSampleTableTotalCount - (amountMajorSampleSize || 0);
    //如果选择的特殊项目,属于极不重要上限的,则需要增加
    inStatSampleParameter.toBeTestSampleSize +=
      inStatSampleParameter.lessThanUnimportantMaxSampleSize || 0;
    inStatSampleParameter.toBeTestAmountSum +=
      inStatSampleParameter.lessThanUnimportantMaxSampleSum || 0;
    //如果选择的特殊项目,属于金额重大的,则需要增加
    inStatSampleParameter.toBeTestSampleSize +=
      inStatSampleParameter.greaterThanAmountMajorMinSampleSize || 0;
    inStatSampleParameter.toBeTestAmountSum +=
      inStatSampleParameter.greaterThanAmountMajorMinSampleSum || 0;

    inStatSampleParameter.toBeTestSampleSize =
      inStatSampleParameter.toBeTestSampleSize -
      (unimportantSampleSize || 0) -
      (specialSampleSize || 0);
    //如果选择的特殊项目,属于金额重大的,则需要增加
    inStatSampleParameter.toBeTestAmountSum =
      inStatSampleParameter.toBeTestAmountSum -
      (specialAmountSum || 0) -
      (unimportantAmountSum || 0);

    inStatSampleParameter.toBeTestSampleSize =
      inStatSampleParameter.toBeTestSampleSize < 0 ? 0 : inStatSampleParameter.toBeTestSampleSize;
    inStatSampleParameter.toBeTestWhereSql = getToBeTestWhereSql(inStatSampleParameter);

    //E.样本规模(G=(B*E)/(C-(D*F)))
    if (!isSystemOutCalc) {
      //如果系统外计算样本规模大小
      inStatSampleParameter.measurementSampleSize = 0;

      // if (inStatSampleParameter.tolerableMiss) {//可容忍错报

      //预计总体错报,没有值才计算,可以手动改
      if (!inStatSampleParameter.expectedOverallMiss) {
        inStatSampleParameter.expectedOverallMiss = parseFloat(
          (inStatSampleParameter.tolerableMiss / 3).toFixed(2),
        );
      }

      //B.待抽样的测试总体（扣除特定项目后） X E、风险系数
      const value5x8 =
        inStatSampleParameter.toBeTestAmountSum * (inStatSampleParameter.riskCoefficient || 0);
      //D.预计总体错报 X F、扩张系数
      const value7x9 =
        inStatSampleParameter.expectedOverallMiss *
        (inStatSampleParameter.expansionCoefficient || 0);
      //C.可容忍错报(重要性的30%-70%)  - (  /D.预计总体错报 X F、扩张系数	 )
      const value6sub7x9 = inStatSampleParameter.tolerableMiss - value7x9;

      if (value6sub7x9 > 0) {
        inStatSampleParameter.measurementSampleSize = Math.ceil(value5x8 / value6sub7x9);
        //取最小值
        inStatSampleParameter.measurementSampleSize = Math.min(
          inStatSampleParameter.measurementSampleSize,
          inStatSampleParameter.toBeTestSampleSize,
        );
      }
    }
    //如果数字为0,则设置为待抽取的样本数量
    if (inStatSampleParameter.randomSampleParams) {
      inStatSampleParameter.randomSampleParams.extractNumber =
        propsSampleParameterValues?.randomSampleParams?.extractNumber ||
        inStatSampleParameter.measurementSampleSize;
    }
    //则设置为待抽取的样本数量
    if (inStatSampleParameter.ppsSampleParams && inStatSampleParameter.measurementSampleSize) {
      inStatSampleParameter.ppsSampleParams.extractNumber =
        propsSampleParameterValues?.ppsSampleParams?.extractNumber ||
        inStatSampleParameter.measurementSampleSize;
    }
    // F.重大项目数量(减掉重叠的)

    inStatSampleParameter.majorProjectSize =
      (inStatSampleParameter.amountMajorSampleSize || 0) +
      (inStatSampleParameter.specialSampleSize || 0) -
      (inStatSampleParameter.greaterThanAmountMajorMinSampleSize || 0);

    //I、需测试的全部数量(I=G+H)
    inStatSampleParameter.needTestAllSampleSize = Math.min(
      (inStatSampleParameter.measurementSampleSize || 0) +
        (inStatSampleParameter.majorProjectSize || 0),
      curSampleTableTotalCount,
    );

    if (inStatSampleParameter.needTestAllSampleSize != 0) {
      inStatSampleParameter.sampleInterval = Math.floor(
        inStatSampleParameter.toBeTestSampleSize / inStatSampleParameter.needTestAllSampleSize,
      );
    }

    //分层抽样的参数
    // const layerRanges = inStatSampleParameter.layerSampleParams?.layerRanges || [];
    //如果新旧不相同的值,就需要重算
    const isNeedCalcLayerSampleSize = getNeedCalcLayerSampleSize(
      inStatSampleParameter,
      old_toBeTestSampleSize,
      old_toBeTestAmountSum,
      old_measurementSampleSize,
    );

    //如果是没有设置过的,使用初始化的
    if (inStatSampleParameter.layerSampleParams) {
      const propLayerRanges = propsSampleParameterValues?.layerSampleParams?.layerRanges;
      if (propLayerRanges?.length) {
        inStatSampleParameter.layerSampleParams.layerRanges = propLayerRanges;
      } else {
        //分层抽样,如果存在为needSampleSize的个数>0时,要重新计算:
        let needSampleSizeLen = inStatSampleParameter.layerSampleParams.layerRanges?.filter(
          (item) => !item.needSampleSize,
        ).length;
        if (needSampleSizeLen || isNeedCalcLayerSampleSize) {
          inStatSampleParameter.layerSampleParams.layerRanges = getDefaultLayerRanges(
            sampleStepInfo,
            inStatSampleParameter.toBeTestSampleSize,
            inStatSampleParameter.toBeTestAmountSum,
            inStatSampleParameter.measurementSampleSize,
          );
        }
      }
    }

    //系统抽样
    if (inStatSampleParameter.systemSampleParams) {
      if (propsSampleParameterValues?.systemSampleParams?.extractNumber) {
        inStatSampleParameter.systemSampleParams = propsSampleParameterValues?.systemSampleParams;
      } else {
        //如果选择了系统抽样,则设置抽取间隔
        if (inStatSampleParameter.systemSampleParams) {
          //优先使用编辑的
          inStatSampleParameter.systemSampleParams.interval =
            inStatSampleParameter.sampleInterval || 0;
        }

        const sampleNos = getSystemSampleNos(
          inStatSampleParameter.toBeTestSampleSize,
          inStatSampleParameter.systemSampleParams?.interval || 0,
          inStatSampleParameter.systemSampleParams?.extractType == SystemExtractType.asc,
        );
        inStatSampleParameter.systemSampleParams.extractNumber = sampleNos.length;
      }
    }
  }

  /**
   * 抽样的参数
   * @returns
   */
  function getSampleParamsTopTable() {
    return (
      <table className="table-with-borders" style={tableStye}>
        <thead>
          <tr>
            <td
              width="3%"
              style={{ ...thStyle, fontSize: 14, minWidth: 35, paddingLeft: 0, paddingRight: 0 }}
            >
              行次
            </td>
            <td width="27%" style={thStyle}>
              项目
            </td>
            <td width="25%" style={thStyle}>
              参数
            </td>
            <td width="20%" style={thStyle}>
              金额或数值
            </td>
            <td width="10%" style={thStyle}>
              项目数量
            </td>
            <td width="15%" style={thStyle}>
              备注
            </td>
          </tr>
        </thead>
        <tr>
          {/* A.总体（扣除特定项目前） */}
          <td className="text-center">1</td>
          <td className="bolb-font">A.总体（扣除特定项目前）</td>
          <td>{consts.NA}</td>
          <td>
            <NumberBox
              rtlEnabled={true}
              value={sampleStepInfo.projectOverallProps?.curSampleTableAmountSum}
              readOnly={true}
              stylingMode="filled"
              format={consts.numberFormat}
              tabIndex={-1}
            />
          </td>
          <td className="text-center ">
            <a
              title="点击查看样本"
              onClick={() => {
                viewSampleListByWhereSql(
                  `总体样本`,
                  sampleStepInfo.projectOverallProps?.curSampleTableTotalCount || 0,
                  '',
                );
              }}
            >
              <span style={{ marginRight: 5 }}>
                {sampleStepInfo.projectOverallProps?.curSampleTableTotalCount || 0}
              </span>
              <CpasIcon type="icon-shuxing"></CpasIcon>
            </a>

            {/* <NumberBox value={sampleStepInfo.projectOverallProps?.curSampleTableTotalCount}
                    readOnly={true} stylingMode='filled' format={consts.unitGeFormat}
                /> */}
          </td>
          <td className="auto-font-size">
            <TextBox
              stylingMode="filled"
              readOnly={true}
              value="总体的金额、项目数量"
              tabIndex={-1}
            />
          </td>
        </tr>
        <tr>
          {/* 金额重大下限 */}
          <td className="text-center">2</td>
          <td>减：总体中金额重大的项目</td>
          <td className="itemBoxDispalyCenter" style={{ border: 0 }}>
            <div
              style={{ width: '90px', textAlign: 'left' }}
              title={`大于等于${statSampleParameter.amountMajorMin}`}
            >
              金额重大下限
            </div>
            <NumberBox
              value={statSampleParameter.amountMajorMin}
              format={consts.numberFormat}
              min={0}
              width={'calc(98% - 90px)'}
              onFocusIn={textBoxSelectAll}
              onFocusOut={() => getSampleSizeAndAmountOfAmountMajorMin()}
              onValueChanged={async (e: any) => {
                statSampleParameter.amountMajorMin = e.value;
                setStatSampleParameter({ ...statSampleParameter });
              }}
              onEnterKey={() => getSampleSizeAndAmountOfAmountMajorMin()}
            />
          </td>
          <td className="text-center">
            <NumberBox
              rtlEnabled={true}
              value={statSampleParameter.amountMajorAmountSum}
              format={consts.numberFormat}
              readOnly={true}
              tabIndex={-1}
            />
          </td>
          {/* 金额重大下限 个数 */}
          <td className="text-center">
            <a
              title="点击查看样本"
              onClick={() => {
                viewSampleListByWhereSql(
                  `【金额重大下限：${statSampleParameter.amountMajorMin}】样本`,
                  statSampleParameter.amountMajorSampleSize,
                  statSampleParameter.amountMajorWhereSql,
                );
              }}
            >
              <span style={{ marginRight: 5 }}>{statSampleParameter.amountMajorSampleSize}</span>
              <CpasIcon type="icon-shuxing"></CpasIcon>
            </a>

            {/* <NumberBox value={statSampleParameter.amountMajorSampleSize}
                    readOnly={true} stylingMode='filled' format={consts.unitGeFormat}
                /> */}
          </td>
          <td></td>
        </tr>
        <tr>
          {/* 总体中性质特殊的重大项目 */}
          <td className="text-center">3</td>
          <td>　　总体中性质特殊的重大项目</td>
          <td className="itemBoxDispalyCenter">
            <div style={{ width: '90px', textAlign: 'left' }}>特殊重大项目</div>
            <Button
              width="calc(98% - 90px)"
              text={`请选择项目`}
              icon="fieldchooser"
              stylingMode="outlined"
              style={{ marginBottom: 4 }}
              onClick={selectSpecialSampleListPopup}
            ></Button>
            <Badge
              showZero={false}
              style={{ marginLeft: 3, cursor: 'default' }}
              count={statSampleParameter.lessThanUnimportantMaxSampleSize}
              title={`有 ${statSampleParameter.lessThanUnimportantMaxSampleSize} 个属于极不重要项目`}
            />
            <Badge
              showZero={false}
              style={{ marginLeft: 3, cursor: 'default' }}
              count={statSampleParameter.greaterThanAmountMajorMinSampleSize}
              title={`有 ${statSampleParameter.greaterThanAmountMajorMinSampleSize} 个属于金额重大项目`}
            />
          </td>
          <td>
            <NumberBox
              rtlEnabled={true}
              value={statSampleParameter.specialAmountSum}
              format={consts.numberFormat}
              readOnly={true}
              tabIndex={-1}
            />
          </td>
          <td className="text-center">
            <a
              title="点击查看样本"
              onClick={() => {
                viewSampleListByWhereSql(
                  `性质特殊的重大项目样本`,
                  statSampleParameter.specialSampleSize,
                  statSampleParameter.specialWhereSql,
                );
              }}
            >
              <span style={{ marginRight: 5 }}>{statSampleParameter.specialSampleSize}</span>
              <CpasIcon type="icon-shuxing"></CpasIcon>
            </a>
          </td>
          <td></td>
        </tr>
        <tr>
          {/* 总体中极不重要项目 */}
          <td className="text-center">4</td>
          <td>　　总体中极不重要项目</td>
          <td className="itemBoxDispalyCenter" style={{ border: 0 }}>
            <div
              style={{ width: '90px', textAlign: 'left' }}
              title={`小于等于${statSampleParameter.unimportantMax}`}
            >
              极不重要上限
            </div>
            <NumberBox
              value={statSampleParameter.unimportantMax}
              format={consts.numberFormat}
              min={0}
              width={'calc(98% - 90px)'}
              onFocusIn={textBoxSelectAll}
              onFocusOut={() => getSampleSizeAndAmountOfUnimportantMax()}
              onValueChanged={async (e: any) => {
                statSampleParameter.unimportantMax = e.value;
                setStatSampleParameter({ ...statSampleParameter });
              }}
              onEnterKey={() => getSampleSizeAndAmountOfUnimportantMax()}
            />
          </td>
          <td>
            <NumberBox
              rtlEnabled={true}
              value={statSampleParameter.unimportantAmountSum}
              readOnly={true}
              stylingMode="filled"
              format={consts.numberFormat}
              tabIndex={-1}
            />
          </td>
          {/* 极不重要个数 */}
          <td className="text-center">
            <a
              title="点击查看样本"
              onClick={() => {
                viewSampleListByWhereSql(
                  `【极不重要上限：${statSampleParameter.unimportantMax}】样本`,
                  statSampleParameter.unimportantSampleSize,
                  statSampleParameter.unimportantWhereSql,
                );
              }}
            >
              <span style={{ marginRight: 5 }}>{statSampleParameter.unimportantSampleSize}</span>
              <CpasIcon type="icon-shuxing"></CpasIcon>
            </a>
          </td>
        </tr>
        <tr>
          {/* B.待抽样的测试总体（扣除特定项目后） */}
          <td className="text-center">5</td>
          <td className="bolb-font">B.待抽样的测试总体(扣除特定项目后)</td>
          <td>5 = 1 - 2 - 3 - 4</td>
          <td>
            <NumberBox
              rtlEnabled={true}
              value={statSampleParameter.toBeTestAmountSum}
              readOnly={true}
              stylingMode="filled"
              format={consts.numberFormat}
              tabIndex={-1}
            />
          </td>
          <td className="text-center">
            <a
              title="点击查看样本"
              onClick={() => {
                viewSampleListByWhereSql(
                  `【待抽样的测试总体(扣除特定项目后)】样本`,
                  statSampleParameter.toBeTestSampleSize,
                  getToBeTestWhereSql(statSampleParameter),
                );
              }}
            >
              <span style={{ marginRight: 5 }}>{statSampleParameter.toBeTestSampleSize}</span>
              <CpasIcon type="icon-shuxing"></CpasIcon>
            </a>
          </td>
          <td></td>
        </tr>
        <tr style={{ display: isSystemOutCalcDisplay }}>
          {/* C.可容忍错报 */}
          <td className="text-center">6</td>
          <td>C.可容忍错报{/* (重要性的30%-70%) */}</td>
          <td style={{ padding: 5 }}>
            <div style={{ width: '100px', textAlign: 'left' }}>{getRedStarHtml()}可容忍错报</div>
          </td>
          <td className="itemBoxDispalyCenter" style={{ border: 0 }}>
            <NumberBox
              rtlEnabled={true}
              value={statSampleParameter.tolerableMiss}
              format={consts.numberFormat}
              //width={'calc(98% - 100px)'}
              onFocusIn={textBoxSelectAll}
              onFocusOut={tolerableMissValueChange}
              onValueChanged={async (e: any) => {
                statSampleParameter.tolerableMiss = e.value;
                setStatSampleParameter({ ...statSampleParameter });
              }}
              onEnterKey={tolerableMissValueChange}
            />
          </td>
          <td className="text-center">{consts.NA}</td>
          <td></td>
        </tr>
        <tr style={{ display: isSystemOutCalcDisplay }}>
          {/* D、预计总体错报 */}
          <td className="text-center">7</td>
          <td>D.预计总体错报</td>
          <td style={{ padding: 5 }}>
            <div style={{ /* width: '150px', */ textAlign: 'left' }}>
              {getRedStarHtml()}默认为可容忍错报的1/3
            </div>
          </td>
          <td className="itemBoxDispalyCenter" style={{ border: 0 }}>
            <NumberBox
              rtlEnabled={true}
              value={statSampleParameter.expectedOverallMiss}
              format={consts.numberFormat}
              /* width={'calc(98% - 100px)'} */
              onFocusIn={textBoxSelectAll}
              onFocusOut={expectedOverallMissValueChange}
              onValueChanged={async (e: any) => {
                statSampleParameter.expectedOverallMiss = e.value;
                setStatSampleParameter({ ...statSampleParameter });
              }}
              onEnterKey={expectedOverallMissValueChange}
            />
          </td>
          <td className="text-center">{consts.NA}</td>
          <td></td>
        </tr>

        <tr style={{ display: isSystemOutCalcDisplay }}>
          {/*  E、风险系数 */}
          <td className="text-center">8</td>
          <td>E、风险系数</td>
          <td style={{ padding: 5 }}>
            <div className="itemBoxDispalyCenter">
              <div style={{ width: '120px', textAlign: 'left', fontSize: 13 }}>
                {getRedStarHtml()}可接受的风险水平
              </div>
              <SelectBox
                width={'calc(98% - 120px)'}
                dataSource={acceptableRiskArray}
                valueExpr="value"
                displayExpr="text"
                placeholder="选择"
                //style={{ marginRight: 5 }}
                value={statSampleParameter.acceptableRisk}
                onValueChanged={(e: any) => {
                  statSampleParameter.acceptableRisk = e.value;
                  const { acceptableRisk, acceptableDevSize } = statSampleParameter;
                  if (acceptableRisk) {
                    //扩张系数
                    statSampleParameter.expansionCoefficient =
                      getExpansionCoefficient(acceptableRisk);
                    //可接受的偏差数量
                    if (acceptableDevSize) {
                      statSampleParameter.riskCoefficient = getRiskCoefficient(
                        acceptableRisk,
                        acceptableDevSize,
                      );
                    }
                  }
                  calcAmountSampleSize();
                  setStatSampleParameter({ ...statSampleParameter });
                }}
              />
            </div>
            <div className="itemBoxDispalyCenter" style={{ marginTop: 2 }}>
              <div style={{ width: '120px', textAlign: 'left', fontSize: 13 }}>
                {getRedStarHtml()}可接受的偏差数量
              </div>
              <SelectBox
                width={'calc(98% - 120px)'}
                placeholder="选择"
                dataSource={acceptableDevArray}
                valueExpr="value"
                displayExpr="text"
                value={statSampleParameter.acceptableDevSize}
                //style={{ marginRight: 10 }}
                onValueChanged={(e: any) => {
                  statSampleParameter.acceptableDevSize = e.value;
                  const { acceptableRisk, acceptableDevSize } = statSampleParameter;
                  if (acceptableRisk && acceptableDevSize) {
                    //可接受的偏差数量
                    statSampleParameter.riskCoefficient = getRiskCoefficient(
                      acceptableRisk,
                      acceptableDevSize,
                    );
                  }
                  calcAmountSampleSize();
                  setStatSampleParameter({ ...statSampleParameter });
                }}
              />
            </div>
          </td>
          <td>
            <NumberBox
              rtlEnabled={true}
              value={statSampleParameter.riskCoefficient}
              readOnly={true}
              stylingMode="filled"
              tabIndex={-1}
            />
          </td>
          <td className="text-center">
            <Button
              hint="查看风险系数表"
              text={`风险系数表`}
              stylingMode="outlined"
              style={{ marginTop: 4 }}
              onClick={openRiskCoefficientPopup}
            ></Button>
          </td>
          <td></td>
        </tr>

        <tr style={{ display: isSystemOutCalcDisplay }}>
          {/* F、扩张系数 */}
          <td className="text-center">9</td>
          <td>F、扩张系数</td>{' '}
          <td style={{ padding: 5 }}>
            <div style={{ width: '100px', textAlign: 'left' }}>扩张系数</div>
          </td>
          <td>
            <NumberBox
              rtlEnabled={true}
              value={statSampleParameter.expansionCoefficient}
              readOnly={true}
              tabIndex={-1}
              stylingMode="filled"
            />
          </td>
          <td className="text-center">
            <Button
              hint="查看扩张系数表"
              text={`扩张系数表`}
              stylingMode="outlined"
              style={{ marginTop: 4 }}
              onClick={openExpansionCoefficientPopup}
            ></Button>
          </td>
          <td></td>
        </tr>

        <tr>
          {/*  G.样本规模(E=B*D/C) */}
          <td className="text-center">{isSystemOutCalc ? 6 : 10}</td>
          <td className="bolb-font">G.样本规模{/*[G=(B*E)/(C-(D*F))]*/}</td>
          <td>{isSystemOutCalc ? systemOutHint : '10=(5 * 8) / (6 - (7 * 9))'}</td>
          <td className="text-right">{systemOutHint ? '请输入样本规模' : consts.NA}</td>
          <td className="text-center">
            {isSystemOutCalc ? (
              <NumberBox
                value={statSampleParameter.measurementSampleSize}
                //format={consts.numberFormat}
                // rtlEnabled={true}
                min={0}
                max={statSampleParameter.toBeTestSampleSize}
                hint={`样本规模最大值 ${statSampleParameter.toBeTestSampleSize}`}
                onFocusIn={textBoxSelectAll}
                // onFocusOut={measurementSampleSizeValueChange} 手工输入时不要这个事件
                onValueChange={async (e: any) => {
                  statSampleParameter.measurementSampleSize = e;
                  measurementSampleSizeValueChange();
                }}
                onEnterKey={measurementSampleSizeValueChange}
              />
            ) : (
              statSampleParameter.measurementSampleSize
            )}
          </td>
          <td>
            {' '}
            {statSampleParameter.measurementSampleSize >
              (statSampleParameter.toBeTestSampleSize || 0) && (
              <span style={{ color: 'red' }}>样本规模应小于等于待抽样的测试总体</span>
            )}
          </td>
        </tr>
        <tr>
          {/*  H.重大项目数量 */}
          <td className="text-center">{isSystemOutCalc ? 7 : 11}</td>
          <td>H.重大项目数量</td>
          <td>{isSystemOutCalc ? 7 : 11} = 2 + 3</td>
          <td className="text-right">{consts.NA}</td>
          <td className="text-center">{statSampleParameter.majorProjectSize}</td>
          <td></td>
        </tr>
        <tr>
          {/*  F.重大项目数量 */}
          <td className="text-center">{isSystemOutCalc ? 8 : 12}</td>
          <td className="bolb-font">I.需测试的全部数量{/* (G=E+F) */}</td>
          <td>{isSystemOutCalc ? '8 = 6 + 7' : '12 = 10 + 11'}</td>
          <td className="text-right">{consts.NA}</td>
          <td className="text-center">{statSampleParameter.needTestAllSampleSize}</td>
          <td></td>
        </tr>
        <tr>
          {/*  J、样本间隔(J=B/G) */}
          <td className="text-center">{isSystemOutCalc ? 9 : 13}</td>
          <td className="bolb-font">J.样本间隔</td>
          <td>{isSystemOutCalc ? '9 = 5 / 8' : '13 = 5 / 12'}</td>
          <td className="text-right">{consts.NA}</td>
          <td className="text-center">{statSampleParameter.sampleInterval}</td>
          <td></td>
        </tr>
      </table>
    );
  }
  return (
    <ScrollView
      id="statSampleParameterScrollview"
      height="100%"
      style={
        {
          /*  border: '1px solid red' */
        }
      }
    >
      <div style={{ width: '99%' }}>
        <button
          id="btnStatCalc"
          ref={btnStatCalcRef}
          style={{ display: 'none' }}
          onClick={async () => {
            await getSampleSizeAndAmountOfAmountMajorMin(undefined, true);
            await getSampleSizeAndAmountOfUnimportantMax(undefined, false);
            msgInfo('数据加载中...', 500, undefined, '300px'); //这个界面才更新
            msgInfo('数据加载中...', 500, undefined, '300px'); //这个界面才更新
          }}
        >
          计算
        </button>
        {/* 风险系数表  */}
        {isNeedRiskCoefficientPopup && (
          <RiskCoefficientPopup
            statSampleParameter={statSampleParameter}
            setStatSampleParameter={setStatSampleParameter}
            ref={riskCoefficientPopupRef}
          />
        )}
        {/* 扩张系数表  */}
        {isNeedExpansionCoefficientPopup && (
          <ExpansionCoefficientPopup
            statSampleParameter={statSampleParameter}
            setStatSampleParameter={setStatSampleParameter}
            ref={expansionCoefficientPopupRef}
          />
        )}
        {/* 查看样本 */}
        {isNeedViewSampleListPopup && <ViewSampleListPopup ref={viewSampleListPopupRef} />}
        {/*  抽样参数top表 */}
        {getSampleParamsTopTable()}

        <Toolbar style={{ marginTop: 8 }} id="statSample_SampleMethodToolBar">
          <Item location="before">
            <RadioGroup
              layout="horizontal"
              dataSource={getStatSampleMethodList()}
              value={statSampleParameter.sampleMethod}
              onValueChanged={sampleMethodOnValueChanged}
            />
          </Item>
          <Item location="before" locateInMenu={'auto'}>
            <div className="itemBoxDispalyLeft">
              <TextBox
                label={`已抽样本，共 ${statSampleParameter.sampledResult?.sampledSize || 0} 个`}
                hint={`已抽样本，共 ${statSampleParameter.sampledResult?.sampledSize || 0} 个`}
                width={() => {
                  const itemElement = document.getElementById('statSample_SampleMethodToolBar');
                  if (itemElement) {
                    return itemElement.offsetWidth - 300;
                  } else {
                    return window.innerWidth - 860;
                  }
                }}
                style={{ marginTop: 0, marginLeft: 20, paddingTop: 5, marginRight: 5 }}
                readOnly={true}
                tabIndex={-1}
                value={getValueTextTop500(statSampleParameter.sampledResult?.sampleTextFieldValues)}
              />
              <div className="table-with-borders" style={{ border: 0 }}>
                <Button
                  text="查看"
                  hint="查看已抽取样本"
                  style={{ marginRight: 4 }}
                  onClick={async () => {
                    if (statSampleParameter.sampledResult?.sampledSize) {
                      const whereSql = await getWhereSqlBySampleList(
                        sampleStepInfo,
                        statSampleParameter.sampledResult?.sampledList || [],
                      );

                      viewSampleListByWhereSql(
                        '已抽样本',
                        statSampleParameter.sampledResult?.sampledSize,
                        whereSql,
                      );
                    } else {
                      msgError('还没有抽取到样本!');
                    }
                  }}
                ></Button>
              </div>
            </div>
          </Item>

          <Item location="after">
            <Button
              text="试抽取"
              type="default"
              style={{ marginRight: 0 }}
              disabled={loading || statSampleParameter.sampleMethod === SampleMethod.manual}
              onClick={async () => {
                //分层
                if (statSampleParameter.sampleMethod === SampleMethod.layer) {
                  layerSampleRef.current?.saveEditData();
                  //  await layerSampleRef.current?.reCalcUnSampleSize(statSampleParameter,true);
                }
                if (statSampleParameter.sampleMethod === SampleMethod.manual) {
                  return msgError('请选择抽样方法!');
                }
                setLoading(true);
                try {
                  statSampleParameter.sampledResult = await getTrySampleResult(
                    sampleStepInfo,
                    statSampleParameter,
                  );
                  setLoading(false);
                  if (statSampleParameter.sampledResult.sampledSize) {
                    msgInfo(`成功抽取 ${statSampleParameter.sampledResult.sampledSize} 个!`);
                  }
                } finally {
                  setLoading(false);
                }

                // console.log('sampleStepInfo:', JSON.stringify(sampleStepInfo))
                setStatSampleParameter({ ...statSampleParameter });
              }}
            ></Button>
          </Item>
        </Toolbar>

        {
          //随机抽样
          statSampleParameter.sampleMethod == SampleMethod.random && (
            <div style={{ ...sampleMethodStyle }}>
              <RandomSample
                sampleParameterValues={statSampleParameter}
                setSampleParameterValues={setStatSampleParameter}
              ></RandomSample>
            </div>
          )
        }
        {
          //系统抽样

          statSampleParameter.sampleMethod == SampleMethod.system && (
            <div style={{ ...sampleMethodStyle }}>
              <SystemSample
                sampleParameterValues={statSampleParameter}
                setSampleParameterValues={setStatSampleParameter}
                projectOverallProps={sampleStepInfo.projectOverallProps}
              ></SystemSample>
            </div>
          )
        }
        {
          //分层抽样

          statSampleParameter.sampleMethod == SampleMethod.layer && (
            <div style={{ ...sampleMethodStyle }}>
              <LayerSample
                ref={layerSampleRef}
                sampleParameterValues={statSampleParameter}
                setSampleParameterValues={setStatSampleParameter}
              ></LayerSample>
            </div>
          )
        }
        {/* 任意抽样 */}
        {statSampleParameter.sampleMethod == SampleMethod.manual && (
          <div style={{ ...sampleMethodStyle }}>
            <ManualSample
              ref={manualSampleRef}
              sampleParameterValues={statSampleParameter}
              setSampleParameterValues={setStatSampleParameter}
            ></ManualSample>
          </div>
        )}
        {/* PPS抽样 */}
        {statSampleParameter.sampleMethod == SampleMethod.pps && (
          <div style={{ ...sampleMethodStyle }}>
            <PPSSample
              sampleParameterValues={statSampleParameter}
              setSampleParameterValues={setStatSampleParameter}
            />
          </div>
        )}
        {/* 抽样结果2: 重大项目统计,特殊项目统计 */}
        {/* 
            {getSampledResultTable2(sampleStepInfo,statSampleParameter)} */}

        {/* 抽样结果表1,已抽统计 */}
        {getSampledResultTable1(sampleStepInfo, statSampleParameter)}

        <LoadPanel visible={loading} />
      </div>
    </ScrollView>
  );
});
